package com.agadmin.controller;

import com.agadmin.manage.handle.software.checkKey.CheckKeyValid;
import com.agadmin.manage.vo.reponse.software.CheckKeyResponse;
import com.agadmin.manage.vo.request.software.CheckKeyRequest;
import com.agadmin.response.GlobalResponseBody;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/api/check")
public class CheckKeyController {

    @Resource
    CheckKeyValid valid;


    @GlobalResponseBody
    @PostMapping("/key")
    private CheckKeyResponse checkKeyValid(@RequestBody  CheckKeyRequest req){

        log.info("start-------------");

        if(req.getSoftwareKey()==null){
            CheckKeyResponse res=new  CheckKeyResponse();
            res.setCode(402);
            res.setError("software key can't be null");
            return res;
        }
        CheckKeyResponse res = valid.verifyKey(req.getSoftwareKey());
        return res;
    }

}
